//继承(inheritance)：共性抽取，层次结构，代码复用-》体现了由简单到复杂的认知过程

#ifdef a
#include<iostream>
using namespace std;
//父类/基类--》共性
class animal {
public:
	void Breah() {
		cout << _name << "在呼吸" << endl;
	}
	void Sleep() {
		cout << _name << "在睡觉" << endl;
	}
	void Eat() {
		cout << _name << "在吃饭" << endl;
	}
	string _name;
	string _gender;
	size_t _age;
};

//子类/派生类->基类的扩展，具有个性
class Dog :public animal
{
public:
	Dog(const string& name, const string& gender, const string& color, const size_t age)
	{
		_name = name;
		_gender = gender;
		_color = color;
		_age = age;
	}

	void Color() {
		cout << _name << "颜色是" << _color << endl;
	}

	string _color;
};
class Cat : public animal
{
	Cat(const string& name, const string& gender, const string& temper, const size_t age)
	{
		_name = name;
		_gender = gender;
		_temper = temper;
		_age = age;
	}

	void Temper() {
		cout << _name << "脾气是" << _temper << endl;
	}

	string _temper;

}; 

//无意义，没有个性，与基类重复
class Pig {

}; 
int main() {
	Dog d("大黄", "公", "黄色", 3);
	d.Sleep();
	return 0;
}

#endif


#ifdef a
#include<iostream>
using namespace std;
//继承了什么
class Base {
public:
	void Set_Base(int pub, int pro, int pri)
	{
		_pub = pub;
		_pro = pro;
		_pri = pri;
	}

	void Print() {
		cout << _pub << ' ' << _pro << ' ' << _pri << endl;
	}
	int _pub;
protected:
	int _pro;
private:
	int _pri;
};

class child : public Base
{
};
int main() {
	//类的大小
	cout << sizeof(child) << endl;
	//14 说明将基类的成员变量都继承下来了

	Base d;
	d.Set_Base(1, 2, 3);
	d.Print();
	//成员函数也继承了成员函数
	return 0;
}
#endif

